package cn.edu.bs.web.response;

/**
 * @author bs
 */
public class APIResult<T> {

    private Integer code;

    private String message;

    private T result;

    public APIResult() {
    }

    public APIResult(Integer code, String message, T data) {
        this.setCode(code);
        this.setMessage(message);
        this.setResult(data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public String toJson() {
        return "{" +
                "\"code\": \"" + code + "\"," +
                "\"message\": \"" + message + "\"," +
                "\"data\": \"" + result + "\"}";
    }

    @Override
    public String toString() {
        return toJson();
    }
}
